package com.cmower.dzone.lambda;

/**
 * @author 沉默王二
 */
public class ModifyVariableInsideLambda {
    static int limit = 10;
    public static void main(String[] args) {
        Runnable r = () -> {
            limit = 5;
            for (int i = 0; i < limit; i++) {
                System.out.println(i);
            }
        };
        new Thread(r).start();

final int a;
a = 1;
// a = 2;
// 由于 a 是 final 的，所以不能被重新赋值

int b;
b = 1;
// b 此后再未更改
// b 就是 effectively final

int c;
c = 1;
// c 先被赋值为 1，随后又被重新赋值为 2
c = 2;
// c 就不是 effectively final
    }
}
